#include <REGX52.H>
#include "Delay.h"

sbit RCK = 0xB5;	//存储寄存器时钟
sbit SER = 0xB4;
sbit SCK = 0xB6;	// 串行输入时钟

/**
  * @brief   点阵LED初始化函数
  * @details 
  * @param   
  * @retval  
  */
void MatrixLED_Init() {
	SCK = 0;
	RCK = 0;
}

/**
  * @brief   通过设置74HC595，来控制点阵LED的每一行高低电平
  * @details 
  * @param   byte 对应每一行高低电平，低位到高位对应DPa~DPh，高电平开启
  * @retval  
  */
void _74HC595_WriteByte(unsigned char byte) {
	unsigned char i;
	for (i = 0; i < 8; i++) {
		SER = byte >> 7;
		byte <<= 1;
		SCK = 1;
		SCK = 0;
	}
	RCK = 1;
	RCK = 0;
}

/**
  * @brief   显示点阵LED中的一列
  * @details 
  * @param   column 显示第几列，1~8
  * @param   byteData 列中哪几个led亮，1开启
  * @retval  
  */
void MatrixLED_ShowColumn(unsigned char column, unsigned char byteData) {
	_74HC595_WriteByte(byteData);
	P0 = ~(0x80 >> (column - 1));
	Delay(1);
	P0 = 0xFF;
}